<template>
  <div>
    <dialog-edit :visible.sync="dialogVisible" :title="'字典类型'" :editModel="editModel" :api="api" :form="form"
      :formRules="formRules" @onSave="onSave">
      <dym-form :editModel="editModel" :componentList="componentList" :formValue.sync="form"
        >
        </dym-form>
    </dialog-edit>
  </div>
</template>
<script>
  import BaseDialog from '@/pages/BaseDialog'
  import DialogEdit from '@/components/dialog/DialogEdit'
  import dymForm from '@/components/element/dymForm'
  export default {
    extends: new BaseDialog(),
    components: {
      DialogEdit,
      dymForm
    },
    data () {
      return {
        componentList: [
          {
            label: '字典名称：',
            prop: 'label', // 表单验证传入的值
            labelWidth: '110px',
            componentName: 'el-input',
            cols: [12, 12, 12, 12],
            placeholder: '请输入',
            value: 'label' // 字段显示的值
          },
          {
            label: '字典类型：',
            prop: 'type', // 表单验证传入的值
            labelWidth: '110px',
            componentName: 'el-input',
            cols: [12, 12, 12, 12],
            placeholder: '请输入',
            value: 'type' // 字段显示的值
          },
          {
            label: '排序号',
            prop: 'sort', // 表单验证传入的值
            labelWidth: '110px',
            componentName: 'el-input',
            cols: [12, 12, 12, 12],
            placeholder: '请输入',
            value: 'sort' // 字段显示的值
          },
          {
            label: '状态',
            prop: 'useable', // 表单验证传入的值
            labelWidth: '110px',
            componentName: 'dict',
            dictTypeCode: 'useable',
            cols: [12, 12, 12, 12],
            placeholder: '请输入',
            value: 'useable' // 字段显示的值
          },
          {
            label: '备注信息',
            prop: 'remarks', // 表单验证传入的值
            labelWidth: '110px',
            componentName: 'el-input',
            type: 'textarea',
            cols: [24, 24, 24, 24],
            placeholder: '请输入',
            value: 'remarks' // 字段显示的值
          }
        ],
        // 表单验证
        formRules: {
          useable: [{ required: true, message: '不能为空', trigger: 'blur' }],
          label: [{ required: true, message: '不能为空', trigger: 'blur' }],
          type: [{ required: true, message: '不能为空', trigger: 'blur' }]
        }
      }
    },
    methods: {
      // 弹框保存后查询
      onSave () {
        // 操作后重新查询数据字典
        this.$store.dispatch('GetDictionarys', 'reload')
        this.$emit('handSearch')
      }
    }
  }
</script>
